package dto

import (
	"encoding/json"
	basedto "gitee.com/ichub/gofactroy/common/ichubbase/dto"
	"gitee.com/ichub/gofactroy/common/shop/model"
)

type EmployeeQueryParam struct {
	Current    int32  `json:"current"`
	PageSize   int32  `json:"page_size"`
	OrderBys   string `json:"order_bys"`
	FuzzyQuery bool   `json:"fuzzy_query"`
	EsQuery    bool   `json:"es_query"`

	Param *EmployeeParam `json:"param"`
}

type EmployeeParam struct {
	DateRanges   map[string][]int64  `json:"date_ranges,string"`
	IntRanges    map[string][]int64  `json:"int_ranges,string"`
	StringRanges map[string][]string `json:"string_ranges"`
	InRanges     map[string]string   `json:"in_ranges"`

	model.EmployeeVo
}

func (param *EmployeeQueryParam) Ini() {
	param.Current = 1
	param.PageSize = 20
	//param.OrderBys = new(string)

	param.FuzzyQuery = false
	param.EsQuery = false

	param.Param = new(EmployeeParam)

	param.Param.DateRanges = make(map[string][]int64)
	param.Param.IntRanges = make(map[string][]int64)
	param.Param.StringRanges = make(map[string][]string)
	param.Param.InRanges = make(map[string]string)

}

func (param *EmployeeQueryParam) ToString() string {
	s, _ := json.MarshalIndent(param, "", "    ")
	return string(s)

}

func (param *EmployeeQueryParam) String() string {
	s, _ := json.Marshal(param)
	return string(s)

}

type EmployeeJsonResult struct {
	Code int32           `json:"code"`
	Msg  string          `json:"msg"`
	Data *model.Employee `json:"data"`
}

func (result *EmployeeJsonResult) String() string {
	s, _ := json.Marshal(result)
	return string(s)

}

func (result *EmployeeJsonResult) ToString() string {
	s, _ := json.MarshalIndent(result, "", "    ")
	return string(s)

}
func (result *EmployeeJsonResult) Success() *EmployeeJsonResult {
	result.Code = basedto.CODE_SUCCESS
	result.Msg = "成功"
	return result
}

func (result *EmployeeJsonResult) SuccessData(data model.Employee) *EmployeeJsonResult {
	result.Code = basedto.CODE_SUCCESS
	result.Msg = "成功"
	result.Data = &data
	return result
}
func (result *EmployeeJsonResult) SuccessMessage(msg string) *EmployeeJsonResult {
	result.Code = basedto.CODE_SUCCESS
	result.Msg = msg

	return result
}

func (result *EmployeeJsonResult) Fail() *EmployeeJsonResult {
	result.Code = basedto.CODE_FAIL
	result.Msg = "失败"
	return result
}

func (result *EmployeeJsonResult) FailMessage(msg string) *EmployeeJsonResult {
	result.Code = basedto.CODE_FAIL
	result.Msg = msg
	return result
}

func (result *EmployeeJsonResult) FailCodeMsg(code int32, msg string) *EmployeeJsonResult {
	result.Code = code
	result.Msg = msg
	return result
}

type EmployeePageResult struct {
	Code int32  `json:"code"`
	Msg  string `json:"msg"`

	Page basedto.PageParam `json:"page"`
	Data []model.Employee  `json:"data"`
}

func (result *EmployeePageResult) String() string {
	s, _ := json.Marshal(result)
	return string(s)

}

func (result *EmployeePageResult) ToString() string {
	s, _ := json.MarshalIndent(result, "", "    ")
	return string(s)

}

func (result *EmployeePageResult) SetData(s []model.Employee) {
	result.Data = s
}

func (result *EmployeePageResult) GetData() []model.Employee {

	return result.Data
}

func (result *EmployeePageResult) Success() *EmployeePageResult {
	result.Code = basedto.CODE_SUCCESS
	result.Msg = "成功"
	return result
}

func (result *EmployeePageResult) SuccessData(data []model.Employee) *EmployeePageResult {
	result.Code = basedto.CODE_SUCCESS
	result.Msg = "成功"
	//result.Data = data
	return result
}
func (result *EmployeePageResult) SuccessMessage(msg string) *EmployeePageResult {
	result.Code = basedto.CODE_SUCCESS
	result.Msg = msg
	return result
}

func (result *EmployeePageResult) Fail() *EmployeePageResult {
	result.Code = basedto.CODE_FAIL
	result.Msg = "失败"
	return result
}

func (result *EmployeePageResult) FailMessage(msg string) *EmployeePageResult {
	result.Code = basedto.CODE_FAIL
	result.Msg = msg
	return result
}

func (result *EmployeePageResult) FailCodeMsg(code int32, msg string) *EmployeePageResult {
	result.Code = code
	result.Msg = msg
	return result
}
